package org.idea.spring.bean.beaninstance;

import org.idea.spring.bean.beandefinitionbuilder.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 默认的bean初始化案例
 *
 * @Author idea
 * @Date created in 8:13 上午 2020/7/9
 */
public class DefaultBeanInstanceDemo {

    public static void main(String[] args) {
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("bean-instance-context.xml");
        User user = beanFactory.getBean("user-by-static-method", User.class);
        User userByInstanceMethod = beanFactory.getBean("user-by-instance-method", User.class);
        User springUserFactoryBean = beanFactory.getBean("spring-user-factory-bean",User.class);

        System.out.println(springUserFactoryBean);

        System.out.println(user);
        System.out.println(userByInstanceMethod);

        System.out.println(user == userByInstanceMethod);

    }
}
